<?php

include_once 'model/DBContext.php';
require_once 'ListTablesEndpoint.php';
require_once 'DumpTablesEndpoint.php';

/**
 * This class will be the responsible of reading the XML file which includes the services' settings and
 * depending on the user's request it will invoke the corresponding controller.
 */
class ServiceDispatcher {
	//TODO: configuration depending on the XML and WSDL files.
	
	var $context;
	
	public function launchService($serviceName, $aux, $format) {
		if (is_null($this->context)) {
			$this->context = new DBContext();
		}
		$endpoint = NULL;
		switch ($serviceName) {
			case 'listtables':
				$endpoint = new ListTablesEndpoint();
				$endpoint->runService($this->context, $format);
				break;
			case 'getdata':
				$endpoint = new DumpTablesEndpoint();
				$endpoint->setTable($aux);
				$endpoint->runService($this->context, $format);
				break;
		}
	}
	
}

?>
